package com.lingshu.app.database.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.lingshu.app.database.bean.NotebookBean;

import java.util.List;

import io.reactivex.Completable;
import io.reactivex.Flowable;

/**
 * @author 于定金
 * @version 1.0
 * @Date 2023/12/27 14:18
 * @Description
 */
@Dao
public interface NotebookDao {
    @Query("SELECT * FROM notebooks")
    Flowable<List<NotebookBean>> getAll();

    @Query("SELECT * FROM notebooks WHERE uid=:uid")
    Flowable<NotebookBean> findById(int uid);

    // ||相当于+号
    @Query("SELECT * FROM notebooks WHERE title LIKE '%' || :input || '%' OR content LIKE '%' || :input || '%' ")
    Flowable<List<NotebookBean>> searchNotebook(String input);

    @Update
    Completable update(NotebookBean notebook);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Completable insert(NotebookBean notebook);

    @Delete
    Completable delete(NotebookBean... notebook);
}
